from sklearn.metrics import confusion_matrix,classification_report,multilabel_confusion_matrix
from .map import label_list
def cal_result(y_true,y_pred):
    # TODO:出错
    mcm = multilabel_confusion_matrix(y_true = y_true,y_pred = y_pred,labels = label_list)
    tp = mcm[:,1,1]
    tn = mcm[:,0,0]
    fn = mcm[:,1,0]
    fp = mcm[:,0,1]
    # 灵敏度sensitivity = tp/(tp+fn)
    sensitivity = tp/(tp+fn+1e-10)
    # 特异性specificity = tn/(fp+tn)
    specificity = tn/(fp+tn+1e-10)
    sensitivity_dict = {}
    specificity_dict = {}
    for i in range(len(label_list)):
        sensitivity_dict[label_list[i]] = sensitivity[i]
        specificity_dict[label_list[i]] = specificity[i] 
    return sensitivity_dict,specificity_dict
